//
//  UICollectionView+backImageView.m
//  ContinueEducation
//
//  Created by 迟建国 on 2018/8/2.
//  Copyright © 2018年 CE. All rights reserved.
//

#import "UICollectionView+backImageView.h"

@implementation UICollectionView (backImageView)

#pragma 通用无数据

-(void)setNoCurrentDataImage:(BOOL)noCurrentDataImage
{
    self.currentView.hidden = noCurrentDataImage;
}

-(BOOL)noCurrentDataImage
{
    return self.currentView.hidden;
}
- (UIView *)currentView
{
    UIView *currentView = objc_getAssociatedObject(self, "CurrentView");
    if (!currentView) {
        currentView = [[UIView alloc] initWithFrame:self.bounds];
        [self addSubview:currentView];
        
        currentView.backgroundColor = [UIColor clearColor];
        
        UIImageView *  imageView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 190, 190)];
        //        imageView.contentMode = UIViewContentModeCenter;
        imageView.center = CGPointMake(SCREEN_W/2, self.ce_height/2 - 20);
        imageView.image = [UIImage imageNamed:@"commom_kongyemian"];
        
        [currentView addSubview:imageView];
        
        UILabel *noDataL = [[UILabel alloc] initWithFrame:CGRectMake(30, CGRectGetMaxY(imageView.frame) + 15, SCREEN_W - 60, 20)];
        noDataL.text = @"老师还没有布置过作业呢";
        noDataL.textColor = rgba(51, 51, 51, 1);
        noDataL.textAlignment = NSTextAlignmentCenter;
        noDataL.font = [UIFont systemFontOfSize:14];
        [currentView addSubview:noDataL];
        
        objc_setAssociatedObject(self, "CurrentView", currentView, OBJC_ASSOCIATION_RETAIN_NONATOMIC);
        
    }
    currentView.tag = 199009;
    return currentView;
}

#pragma 打卡无数据

-(void)setNoClockDataImage:(BOOL)noClockDataImage
{
    self.clockView.hidden = noClockDataImage;
}

-(BOOL)noClockDataImage
{
    return self.clockView.hidden;
}
- (UIView *)clockView
{
    UIView *clockView = objc_getAssociatedObject(self, "ClockView");
    if (!clockView) {
        clockView = [[UIView alloc] initWithFrame:self.bounds];
        [self addSubview:clockView];
        
        clockView.backgroundColor = [UIColor clearColor];
        
        UIImageView *  imageView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 190, 190)];
        //        imageView.contentMode = UIViewContentModeCenter;
        imageView.center = CGPointMake(SCREEN_W/2, self.ce_height/2 - 20);
        imageView.image = [UIImage imageNamed:@"commom_kongyemian"];
        
        [clockView addSubview:imageView];
        
        UILabel *noDataL = [[UILabel alloc] initWithFrame:CGRectMake(30, CGRectGetMaxY(imageView.frame) + 15, SCREEN_W - 60, 20)];
        noDataL.text = @"暂无打卡作业";
        noDataL.textColor = rgba(51, 51, 51, 1);
        noDataL.textAlignment = NSTextAlignmentCenter;
        noDataL.font = [UIFont systemFontOfSize:14];
        [clockView addSubview:noDataL];
        
        objc_setAssociatedObject(self, "ClockView", clockView, OBJC_ASSOCIATION_RETAIN_NONATOMIC);
        
    }
    clockView.tag = 199000;
    return clockView;
}
@end
